import Taro from "@tarojs/taro";
import * as api from "../apis";
import { request } from "./http-base";

export const getPhone = async (
  encryptedData: String,
  iv: String,
  sessionKey: String
) => {
  return Taro.request({
    method: "POST",
    url: api.getPhone,
    data: {
      encryptedData,
      iv,
      sessionKey
    }
  });
};

export const getEncryptedData = async (encryptedData: String, iv: String) => {
  return request(api.getEncryptedData, { encryptedData, iv }, "POST");
};

export interface CustomerInfo {
  age?: number;
  avatarUrl?: string;
  height?: number;
  mobile?: string;
  name?: string;
  sex?: string;
  weight?: number;
  nickName?:string
}
export const updateCustomerInfo = async (customerInfo: CustomerInfo) => {
  return request(api.updateUserInfo, customerInfo, "PUT");
};

export const getCustomerInfo = async () => {
  const res = await request(api.getCustomerInfo);
  return res?.data?.data || null;
}
